package PTA_JAVA.Exception.Exception06;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        double s1 = input.nextDouble();
        double s2 = input.nextDouble();
        double s3 = input.nextDouble();
        try {
            Triangle t = new Triangle(s1, s2, s3);
            System.out.println(t);
        } catch (IllegalTriangleException ex) {
            System.out.println(ex.getMessage());
        }
    }
}

class IllegalTriangleException extends Exception {
    private double side1, side2, side3;
    @Override
    public String getMessage() {
        return "Invalid: "+side1+","+side2+","+side3;
    }

    public IllegalTriangleException(double side1, double side2, double side3) {
        this.side1 = side1;
        this.side2 = side2;
        this.side3 = side3;
    }
}

class Triangle {
    private double side1, side2, side3;

    public Triangle(double side1, double side2, double side3) throws IllegalTriangleException {
        //实现
        if (side1 + side2 > side3 && side1 + side3 > side2 && side2 + side3 > side1) {
            this.side1 = side1;
            this.side2 = side2;
            this.side3 = side3;
        } else {
            throw new IllegalTriangleException(side1,side2,side3);
        }
    }

    @Override
    public String toString() {
        return "Triangle [side1=" + side1 + ", side2=" + side2 + ", side3=" + side3 + "]";
    }
}

